# include <iostream>
using namespace std;
# include <vector>

int minSubArrayLen(int target, vector<int>& nums) {
    int left = 0, right = 0;
    int n = nums.size();
    int sum = 0, len = 0;;
    while (right < n)
    {
        sum += nums[right];
        len++;
        while (sum >= target)
        {
            len = min(len, right - left + 1);
            sum -= nums[left];
            left++;
            len--;
        }
        right++;
    }
    return len;
}
int minSubArrayLen(int target, vector<int>& nums) {
    int left = 0, right = 0;
    int n = nums.size();
    int sum = 0, len = 100001;;
    while (right < n)
    {
        sum += nums[right];
        while (sum >= target)
        {
            len = min(len, right - left + 1);
            sum -= nums[left];
            left++;
        }
        right++;
    }
    return len == 100001 ? 0 : len;
}

int main()
{
    vector<int>v1{2,3,1,2,4,3};
    int target = 7;
   cout<<minSubArrayLen(7, v1);
}